package com.ds.common;

import com.github.pagehelper.Page;
import lombok.Getter;
import lombok.Setter;

import java.util.List;

/**
 * @author fs
 * @date 2020/9/8
 */

@Getter
@Setter
public class PageInfo<T> {

    /**
     * 总页数
     */
    private Integer pages;

    /**
     * 总条数
     */
    private Long total;

    /**
     * 数据
     */
    private List<T> list;


    public static <T> PageInfo<T> build(List<T> list) {
        PageInfo<T> rspData = new PageInfo<>();
        if (list instanceof Page page) {
            rspData.setPages(page.getPages());
            rspData.setTotal(page.getTotal());
            rspData.setList(list);
        }
        return rspData;
    }
}
